<?php
class models_loaihang extends connect
{
	function listloaihang()
	{
		$sql = 'SELECT MaLH,TenLH FROM loaihang'; //tao lenh truy van
		$this->query_db($sql); //Thuc thi cau lenh sql 
		return $this->fetchAll();//tra ve tat cac dong trong bang
	}
	function _addloahang($TenLH)
	{
		$sql = "INSERT INTO loaihang VALUES('','$TenLH')";
		$this->query_db($sql);
	}
	function del_loaihang($intMa)
	{
		$sql = "DELETE FROM loaihang WHERE MaLH = $intMa";
		$this->query_db($sql);
	}
	function getLoaiHang($intMa)
	{
		$sql = "SELECT MaLH,TenLH FROM loaihang WHERE MaLH = $intMa";
		$this->query_db($sql);
		return $this->fetchOne();
	}
	function updateLoaiHang($tenLH, $intMa)
	{
		$sql ="
		UPDATE loaihang
		SET TenLH = '$tenLH'
		WHERE MaLH = '$intMa'";
		$this->query_db($sql);
	}
	
	
}
?>